<?php

class CollectionConversionAction extends SzAbstractAction
{
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_JSON,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * 兑换收集币
     *
     * @param int $userId 玩家ID
     * @param array $items {用来兑换的碎片ID : 数量, ...}
     * @param int $reqTime
     * @return SzResponse
     */
    public function execute($userId, $items, $reqTime)
    {
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_COLLECTION_FUNC)) {
            return $this->buildResponse(false);
        }

        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);

        return $this->buildResponse(
            CollectionService::get()->conversion($userId, $items)
        );
    }
}